﻿#region Using directives

using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using NiSis.Entities;
using NiSis.Data;

#endregion

namespace NiSis.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="VTrasportatoreProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract class VTrasportatoreProviderBase : VTrasportatoreProviderBaseCore
	{
        /// <summary>
        /// Trova il Trasportatore utilizzando la chiave primaria del pool
        /// </summary>
        /// <returns></returns>
        public VTrasportatore GetByPool(VPool pool)
        {
            VList<VTrasportatore> list = Get(
                string.Format("Cd_Pool='{0}' and Cd_Comune='{1}' and cd_storico_mensile_rete='{2}'",
                pool.CdPool,pool.CdComune,pool.CdMeseInizioFornitura), "cd_pool");
            VTrasportatore NewInstance = list.Count > 0 ? list[0] : null;
            return NewInstance;
        }

        public VTrasportatore GetByPoolMese(string cdPool, string cdMese)
        {
            VList<VTrasportatore> list = Get(
                string.Format("Cd_Pool='{0}' and cd_storico_mensile_rete='{1}'",
                cdPool, cdMese), "cd_pool");
            VTrasportatore NewInstance = list.Count > 0 ? list[0] : null;
            return NewInstance;

        }
	} // end class
} // end namespace
